﻿using System.Windows;
using Bookvar.ObjectModel;

namespace Bookvar.UI.DragDrop
{
    public class MindmapPanelDragSourceAdvisor : DragSourceAdvisorBase
    {
        public override DragDropEffects SupportedEffects
        {
            get { return DragDropEffects.Copy | DragDropEffects.Move; }
        }

        public override DataObject GetDataObject( UIElement draggedElement, Point offsetPoint )
        {
            base.GetDataObject( draggedElement, offsetPoint );
            var presenter = draggedElement as TopicContentPresenter;
            if ( presenter != null )
            {
                Data.SetData( BookvarDataFormats.Topic.Name, presenter );
            }
            return Data;
        }

        public override bool IsDraggable( UIElement dragElement )
        {
            var presenter = dragElement as TopicContentPresenter;
            if ( presenter != null )
            {
                return !( presenter.Topic is MainTopic );
            }
            return false;
        }
    }
}